﻿
// RiskCopTestDlg.h: 头文件
//

#pragma once
#include "TcpClient.h"
#include "xlnt/xlnt.hpp"

#include <string>
#include <vector>
#include <map>

#include "adapt_data.h"
#include "event_protocol.h"
#include "CStock.h"

using namespace std;

class CRiskCopTestDlg : public CDialogEx
{
// 构造
public:
	CRiskCopTestDlg(CWnd* pParent = nullptr);	// 标准构造函数

// 对话框数据
#ifdef AFX_DESIGN_TIME
	enum { IDD = IDD_RISKCOPTEST_DIALOG };
#endif

	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV 支持

private:
	CString GetModuleDir();
protected:
	HICON m_hIcon;

	// 生成的消息映射函数
	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	DECLARE_MESSAGE_MAP()
public:
	afx_msg void OnTimer(UINT_PTR nIDEvent);
	afx_msg void OnDestroy();
	BOOL PreTranslateMessage(MSG* pMsg);
public:
	void GetTenXunHqSend();
	void ReadAndSend();
	void ReadAndSeqSend();
	void SendOrder(xlnt::worksheet& ws);
	void SendCancel(xlnt::worksheet& ws);
	void SendBargain(xlnt::worksheet& ws);
	void SendHqData(xlnt::worksheet& ws);
private:
	string   m_strFileName;
	boost::asio::io_service io_service_;
	boost::asio::io_service::work work_;  //没有任务时, 也会阻塞

	std::shared_ptr<TcpClient>     client_qh_ptr_ = nullptr;
	std::shared_ptr<TcpClient>     client_order_ptr_ = nullptr;
	
	std::string  cur_stock_reqs_;

	int   cur_order_row_;
	int   cur_cancel_row_;
	int   cur_bargain_row_;
	char* payload_send_buffer_;
	int   cur_sheet_id_;
public:
	afx_msg void OnBnClickedButton1();
	afx_msg void OnBnClickedButton2();
	afx_msg void OnBnClickedButton3();
	afx_msg void OnBnClickedButton4();
	CString m_strIP;
	string strAdr_;
	string strHqPort_ = "10317";
	string strOrderPort_ = "14097";
	CStockManager stock_manager_;
	
	BOOL write_check;
	CString  strSendinfo_;
	CString m_strHqPort;
	CString m_strOrderPort;
	CString m_strFreq;
	
	afx_msg void OnBnClickedCheck3();
};
